package com.wp.redisSpringBoot01.controller;

import com.wp.redisSpringBoot01.entity.Dept;
import com.wp.redisSpringBoot01.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: WangPeng
 * @createTime: 2022/12/07 13:27
 * @description:
 * @version: v1.0
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;


    //restful风格: 根据不同的提交方式调用不同的方法。
    // get---查询 post---添加  delete---删除  put---修改

    @GetMapping("/{id}")
    public Dept findById(@PathVariable int id){
        return deptService.findById(id);
    }

    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return deptService.delete(id);
    }

    @PostMapping
    public Dept save(@RequestBody Dept dept){
        return deptService.save(dept);
    }

    @PutMapping
    public Dept update(@RequestBody Dept dept){
        return deptService.update(dept);
    }

}
